home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8831 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  68 lines

  1. Newsgroups: comp.lang.c
  2. Path: surfnet.nl!sun4nl!hcsrnd!root
  3. From: paulw@gti-ia.nl (Paul Wallis)
  4. Subject: Re: C coding standards
  5. Message-ID: <DnuLzM.8xr@gti-ia.nl>
  6. Sender: root@gti-ia.nl (Operator)
  7. Reply-To: paulw@gti-ia.nl
  8. Organization: GTI Industrial Automation, Apeldoorn
  9. References: <313B4548.45AA@oc.com>
  10. Date: Wed, 6 Mar 1996 13:40:34 GMT
  11.  
  12. Teresa Reiko wrote:
  13. > In this book and others, notably 'Code Complete', these programming
  14. > guides published by Microsoft Press, it is evident why Microsoft put
  15. > so many bugs in Windows 95.  Here are the three worst Microsoft
  16. > coding rules, in my opinion at least:
  17. > Every line of code must contain a comment.
  18. > Any number greater than 2 must be a named constant.
  19. > No procedure may be longer than 25 lines.
  20. > If you follow these rules, you can be sure to write buggy, inefficient
  21. > code that is difficult to revise and will generally look 'dirty'.
  22. > Of course, if this is your intent, that's OK, but...
  23. >
  24. I am sorry, but I feel compelled to answer this, even though the debate does NOT
  25. belong in this newsgroup.  I believe IMHO that you have maligned an excellent book.
  26. I have read this book cover to cover and agreed with 90% of what the author says.
  27. And before you go on to 'slate' me, I think you aught to re-read the book and actually
  28. look at what is said.
  29.  
  30. The Code Complete definately does not say that every line should have a comment.
  31. In fact it says that you should be able to read what the code is meant to do without
  32. resorting to comments every line.  The author tries to put across the idea that
  33. comments bear a purpose and are not a cross to be born.
  34.  
  35. It suggests that a _guideline_ to function length would be one page long; going on
  36. to say that a page could be 25 lines 60 lines or even 120 lines depending upon wha
  37. you use for display.
  38.  
  39. As for ridiculing the fact that numbers greater than 2 should be a named constant.
  40. I really can't see your argument there.  It has, as far as I'm aware, always been
  41. common practice in the 'C' programming community to write:
  42.  
  43.     #define NAME_LIMIT 39
  44.     char    name[NAME_LIMIT];
  45.  
  46. as opposed to:
  47.  
  48.     char    name[39];
  49.  
  50. And IMHO the former is far easier to read an when you wish to upgrade or modify the
  51. length of a name you only have to change the #define as opposed to searching through
  52. all of your code for the number 39 and doing a replace...
  53.  
  54. Regards,
  55.     Paul
  56. ---
  57.  
  58.     =     =
  59.       ===   ===      GTI            Contact me at
  60.    ============      Industrial        paulw@gti-ia.nl
  61.         =     =      Automation b.v.    Of course my opinions 
  62.       ===   ===                    are my own?!  Who else
  63.    ============   The Netherlands       is that mad?!
  64.  
  65.  
  66.